package com.liwei.blog.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.liwei.blog.pojo.Blog;
import com.liwei.blog.pojo.Catalog;
import com.liwei.blog.pojo.User;

/*
* 2018年12月5日
*  liwei
* 
*/
public interface BlogDao extends JpaRepository<Blog, Long>{
	
	/**
	 * 根据用户名分页查询用户列表
	 * @param user
	 * @param title
	 * @param pageable
	 * @return
	 */
	Page<Blog> findByUserAndTitleLikeOrderByCreateTimeDesc(User user, String title, Pageable pageable);
	
	/**
	 * 根据用户名分页查询用户列表
	 * @param user
	 * @param title
	 * @param sort
	 * @param pageable
	 * @return
	 */
	Page<Blog> findByUserAndTitleLike(User user, String title, Pageable pageable);

	Page<Blog> findByCatalog(Catalog catalog,Pageable  pageable);

	//@Query("select * from Blog left join User on  Blog.user.id=User.id where title like '%%' order by create_time asc")
	Page<Blog> findByTitleLikeOrderByCreateTimeDesc(String title,Pageable pageable);

	Page<Blog> findByTitleLike(String title, Pageable pageable);

}
